How to get specific data from a string using pattern